//
//  HAODE
//
//  Created by panquanReabam.com on 15/9/23.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "BusinessShelfDetailViewController.h"
#import "ZJSwitch.h"
#import "HAODEsingleton.h"
#import "UIViewExt.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "UIImageView+WebCache.h"
#import "daogouview.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "shouyinCell.h"
#import "huiyuandengjiViewController.h"
#import "shangpingview.h"
#import "peisongleibieViewController.h"
#import "ToResiduePayViewController.h"
#import "addhuiyuanViewController.h"
#import "huiyuanDetailsViewController.h"
#import "BusinessCouponDetailViewController.h"
#import "saoyisaoViewController.h"
#import "BusinessMemberAddressViewController.h"

#import "PlatformProductTypeListViewController.h"
@interface BusinessShelfDetailViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UITextViewDelegate,UISearchBarDelegate,UIScrollViewDelegate>

@property (strong, nonatomic) NSString*GuideCode;
@property (strong, nonatomic) NSString*whsInTypeCode;
@property (strong, nonatomic) NSString*whsId;
@property (strong, nonatomic) NSString*WhsInType;


@end

@implementation BusinessShelfDetailViewController

{
    UISearchBar *search;
    HAODEsingleton* commdity;
    UIButton* sxBtn;
    UIButton*jiantouBtn;
    UIButton*cardBtn;
    float lastContentOffset;
    UITextField*searchTextField;
    UITextField*zhekoujineTextFied;
    UITextField*songhuoTextFied;
    UITextField*anzhuangTextFied;
    UIButton*daogouname;
    daogouview*daogouView;
    UIButton*leixingBtn;
    UIButton*leixingBtn1;
    UIView*view;
    UIView*view1;
    shangpingview*shangpingView;
    UIScrollView*mainScroll;
    UIScrollView*MYmainScroll;
    UILabel*huiyuanname;
    UIButton *tureBtn;
    UILabel*dingdanhao1;
    BOOL saveAccount;
    UIButton *xuanze;
    UIButton*jiagemingxi1;
    UIButton*DiscountRateSatBtn;
    NSMutableArray* arrrss;
    NSMutableArray* arrrss1;
    NSMutableArray*DiscountRatecode ;
    NSMutableArray*DiscountRatecontent ;
    ZJSwitch *switch2;
    UITextField*dinjinjineTextFied;
    UIButton*EarnestRateSatBtn;
    UILabel* weightke;
    UIView*view2;
    UIView*view3;
    UIView*view4;
    UIView*view5;
    UIView*view6;
    UITextView* tv;
    UILabel * label;
    UIImageView*imagess;
    UILabel*shengyuzhifujiage1;
    UIButton*anzhuangSatBtn;
    UIButton*peisongSatBtn;
    UIView* myToolBar;
    UIButton*hejiMoney;
    
}
@synthesize alt = alt;

-(void)BackAction:(UIButton *)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
    //   [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
   
    
    self.title = self.titleName;
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     backColor,
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
  
    
}








- (void)viewDidLoad
{
    
    [super viewDidLoad];
    
    
    commdity=[HAODEsingleton shared];
    
    
    myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
    myToolBar.backgroundColor=jianpancolor;
    UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
    [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [tubtnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:tubtnDone];
    UIButton*btnDone111=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
    [btnDone111 setTitle:@"确定" forState:UIControlStateNormal];
    [btnDone111 setTitleColor:jianpancolor1 forState:UIControlStateNormal];
    btnDone111 .titleLabel .font=[UIFont systemFontOfSize:daxiao];
    [btnDone111 addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:btnDone111];
    myToolBar.alpha=alp;
    UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
    [dabtn addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:dabtn];
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:commdity.orderId forKey:@"shelfId"];
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    NSLog(@"-----------%@", param);
    
[HttpRequest requestData:@"Business/Shelf/Detail" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
if (isSuccess) {
            NSLog(@"-----------%@", severDataDict.dataDict);
    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];

    
        
        MYmainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,64, ScreenWidth, ScreenHeight)];
        [MYmainScroll setBackgroundColor: zuiqianhuicolor];
        MYmainScroll.delegate = self;
        MYmainScroll.userInteractionEnabled = YES;
        MYmainScroll.scrollEnabled = YES;
        MYmainScroll.showsVerticalScrollIndicator = FALSE;
        MYmainScroll.showsHorizontalScrollIndicator = FALSE;
        [self.view addSubview:MYmainScroll];

    
        view1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 70)];
        view1.backgroundColor=[UIColor whiteColor];
        [MYmainScroll addSubview:view1];
    
        UILabel* shelfNo=[[UILabel alloc]initWithFrame:CGRectMake(15, 15, ScreenWidth-30, 16)];
        shelfNo.text=[[severDataDict.dataDict objectForKey:@"shelf"]objectForKey:@"shelfNo"];
        shelfNo.textColor=[UIColor blackColor];
        shelfNo.font=[UIFont systemFontOfSize:16];
        [view1 addSubview:shelfNo];
    
    
    UILabel *line1=[[UILabel alloc] initWithFrame:CGRectMake(0, 70, ScreenWidth, 0.35)];
    line1.backgroundColor=qianhuicolor;
    [view1 addSubview:line1];
    UILabel* duogou=[[UILabel alloc]initWithFrame:CGRectMake(15, 85/2, 33, contenfot)];
    duogou.text=[NSString stringWithFormat:@"员工"];
    duogou.textColor=zhonghuiColor;
    duogou.font=[UIFont systemFontOfSize:contenfot];
    [view1 addSubview:duogou];
    
  
       NSString *createName1 = [[severDataDict.dataDict objectForKey:@"shelf"]objectForKey:@"createName"];
    UIFont *createNamefont1 = [UIFont systemFontOfSize:contenfot];
    CGSize createNamesize1 = CGSizeMake(ScreenWidth-60, 2000);
    CGSize createNamelabelsize1 = [createName1 sizeWithFont:createNamefont1 constrainedToSize:createNamesize1 lineBreakMode:NSLineBreakByCharWrapping];

    daogouname=[[UIButton alloc]initWithFrame:CGRectMake(duogou.right, 85/2,createNamelabelsize1.width+15,contenfot)];
    [daogouname setTitle:createName1 forState:UIControlStateNormal];
    daogouname.titleLabel.font=[UIFont systemFontOfSize:contenfot];
    daogouname.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
    //[daogouname addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
    [daogouname setTitleColor:shenhuicolor forState:UIControlStateNormal];
    [view1 addSubview:daogouname];
        
        
        
        
        UILabel* orderDate=[[UILabel alloc]initWithFrame:CGRectMake(daogouname.right, 85/2, 33, contenfot)];
        orderDate.text=@"日期";
        orderDate.textColor=zhonghuiColor;
        orderDate.font=[UIFont systemFontOfSize:contenfot];
        [view1 addSubview:orderDate];
        NSRange range={0,10};
        NSString* string =[[[severDataDict.dataDict objectForKey:@"shelf"] objectForKey:@"createDate"] substringWithRange:range];
        UILabel* orderDate1=[[UILabel alloc]initWithFrame:CGRectMake(orderDate.right, 85/2, 180, contenfot)];
        orderDate1.text=string;
        orderDate1.textColor=shenhuicolor;
        orderDate1.font=[UIFont systemFontOfSize:contenfot];
        [view1 addSubview:orderDate1];
    
        
        
        
    
    
    view2=[[UIView alloc]initWithFrame:CGRectMake(0, view1.bottom+10, ScreenWidth, 175/2)];
    view2.backgroundColor=[UIColor whiteColor];
    view2.layer.borderWidth = 0.35;
    view2.layer.borderColor = qianhuicolor.CGColor;
    [MYmainScroll addSubview:view2];
    
    UILabel *line3=[[UILabel alloc] initWithFrame:CGRectMake(15,  175/2/2, ScreenWidth-30, 0.35)];
    line3.backgroundColor=qianhuicolor;
    [view2 addSubview:line3];
    UILabel*leixing=[[UILabel alloc]initWithFrame:CGRectMake(15,0, 200, 175/2/2)];
    leixing.text=@"类型";
    leixing.textColor=zhonghuiColor;
    leixing.font=[UIFont systemFontOfSize:conten14fot];
    [view2 addSubview:leixing];
    leixingBtn=[[UIButton alloc]initWithFrame:CGRectMake(30,  0, ScreenWidth-50,175/2/2)];
    leixingBtn.titleLabel.font=[UIFont systemFontOfSize:conten14fot];
    [leixingBtn setTitle:[[severDataDict.dataDict objectForKey:@"shelf"]objectForKey:@"shelfTypeName"] forState:UIControlStateNormal];
    
    leixingBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;

    [leixingBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [view2 addSubview:leixingBtn];
    
    UILabel*leixing1=[[UILabel alloc]initWithFrame:CGRectMake(15,175/2/2, 200, 175/2/2)];
    leixing1.text=@"仓库";
    leixing1.textColor=zhonghuiColor;
    leixing1.font=[UIFont systemFontOfSize:conten14fot];
    [view2 addSubview:leixing1];
    
    leixingBtn1=[[UIButton alloc]initWithFrame:CGRectMake(30,  175/2/2, ScreenWidth-50,175/2/2)];
    [leixingBtn1 setTitle:[[severDataDict.dataDict objectForKey:@"shelf"]objectForKey:@"whsName"] forState:UIControlStateNormal];
    leixingBtn1.titleLabel.font=[UIFont systemFontOfSize:conten14fot];
    leixingBtn1.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
    [leixingBtn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [view2 addSubview:leixingBtn1];

    
    
        
    view3=[[UIView alloc]initWithFrame:CGRectMake(0, view2.bottom+10, ScreenWidth, 45)];
    view3.backgroundColor=[UIColor whiteColor];
    [MYmainScroll addSubview:view3];
    UILabel *lineL=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.35)];
    lineL.backgroundColor=qianhuicolor;
    [view3 addSubview:lineL];
    
    UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
    shangpingxinxi.text=@"商品信息";
    shangpingxinxi.textColor=[UIColor blackColor];
    shangpingxinxi.font=[UIFont systemFontOfSize:15];
    [view3 addSubview:shangpingxinxi];
    
 
        NSNumber*Total = [[severDataDict.dataDict objectForKey:@"shelf"]objectForKey:@"totalMoney"];
       
        
        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        [numberFormatter setPositiveFormat:@"###,##0.00;"];
        NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:Total.doubleValue]];
        weightke=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-250, 0, 230, 45)];
        weightke.text=[NSString  stringWithFormat:@"共 %@ 件，  ￥%@",[[severDataDict.dataDict objectForKey:@"shelf"]objectForKey:@"totalQuantity"], formattedNumberString];
        weightke.textColor = [UIColor colorWithRed:5.00/255.0 green:18.0/255.0 blue:40.00/255.0 alpha:1];
        weightke.textAlignment = NSTextAlignmentRight;
        weightke.font = [UIFont systemFontOfSize:16];
        
        
        
        NSMutableAttributedString *AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString  stringWithFormat:@"共 %@ 件，  ￥%@",[[severDataDict.dataDict objectForKey:@"shelf"]objectForKey:@"totalQuantity"], formattedNumberString]];
        [AttributedStr2 addAttribute:NSFontAttributeName
         
                               value:[UIFont systemFontOfSize:13.0]
         
                               range:NSMakeRange(0, 8)];
        
        [AttributedStr2 addAttribute:NSForegroundColorAttributeName
         
                               value:zhonghuiColor
         
                               range:NSMakeRange(0, 8)];
        
        
        weightke.attributedText = AttributedStr2;
        [view3 addSubview:weightke];
        
        
        
        UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 45-0.35, ScreenWidth-30, 0.35)];
        lineLabel1.backgroundColor=qianhuicolor;
        [view3 addSubview:lineLabel1];
        
        
        arrrss=[severDataDict.dataDict  objectForKey:@"shelfItem"];
        
        NSLog(@"%@",arrrss);
        if (arrrss.count>0) {
            
            for (int i = 0; i<arrrss.count; i++) {
                
                shangpingView = [[shangpingview alloc]initWithFrame:CGRectMake(0, view3.bottom+(120*i), ScreenWidth, 120)];
                shangpingView.backgroundColor=[UIColor whiteColor];
                [shangpingView.headImageFull setImageWithURL:[[arrrss objectAtIndex:i] objectForKey:@"imageUrlFull"] placeholderImage:[UIImage imageNamed:@""]];
                [shangpingView.headImageFull.layer setCornerRadius:6.0];
                [shangpingView.headImageFull.layer setBorderWidth:0.3];
                [shangpingView.headImageFull.layer setMasksToBounds:YES];
                CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0, 0, 0, 0.3 });
                [shangpingView.headImageFull.layer setBorderColor:colorref2];//边框颜色
                
                shangpingView.itemName.text=[NSString stringWithFormat:@"%@%@",[[arrrss objectAtIndex:i] objectForKey:@"itemCode"],[[arrrss objectAtIndex:i] objectForKey:@"itemName"]];
                
                shangpingView.quantity.text=[NSString stringWithFormat:@"数量 %@",[[arrrss objectAtIndex:i] objectForKey:@"quantity"]];
                
                NSMutableAttributedString *AttributedStr1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"数量 %@",[[arrrss objectAtIndex:i] objectForKey:@"quantity"]]];
                
                [AttributedStr1 addAttribute:NSFontAttributeName
                 
                                       value:[UIFont systemFontOfSize:contenfot]
                 
                                       range:NSMakeRange(0, 3)];
                
                [AttributedStr1 addAttribute:NSForegroundColorAttributeName
                 
                                       value:zhonghuiColor
                 
                                       range:NSMakeRange(0, 3)];
                
                
                shangpingView.quantity.attributedText = AttributedStr1;
                
                
                NSNumber*Total =[[arrrss objectAtIndex:i] objectForKey:@"salePrice"];
                
                NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
                [numberFormatter setPositiveFormat:@"###,##0.00;"];
                NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:Total.doubleValue]];
                shangpingView.dealPrice.text=[NSString stringWithFormat:@"¥ %@",formattedNumberString];
                shangpingView.dealPrice.textColor=hongsecolor;
                shangpingView.itemType.text=[NSString stringWithFormat:@"%@",[[arrrss objectAtIndex:i] objectForKey:@"specName"]];
                
                
                
                
                NSMutableAttributedString *AttributedStr12 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"¥ %@",formattedNumberString]];
                
                [AttributedStr12 addAttribute:NSFontAttributeName
                 
                                        value:[UIFont systemFontOfSize:contenfot]
                 
                                        range:NSMakeRange(0, 1)];
                
                [AttributedStr12 addAttribute:NSForegroundColorAttributeName
                 
                                        value:hongsecolor
                 
                                        range:NSMakeRange(0, 1)];
                
                
                shangpingView.dealPrice.attributedText = AttributedStr12;

                
                
                
                
                
                
                if (i==arrrss.count-1) {
                    UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.35, ScreenWidth, 0.35)];
                    lineLabel1.backgroundColor=qianhuicolor;
                    [shangpingView addSubview:lineLabel1];
                }else{
                    UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 120-0.35, ScreenWidth-30, 0.35)];
                    lineLabel1.backgroundColor=qianhuicolor;
                    [shangpingView addSubview:lineLabel1];
                    
                    
                }
                
                [MYmainScroll addSubview:shangpingView];
                
            }
            
        }
    

       
    
    view6=[[UIView alloc]initWithFrame:CGRectMake(0, shangpingView.bottom+10, ScreenWidth, 120)];
    view6.backgroundColor=[UIColor whiteColor];
    view6.layer.borderWidth = 0.35;
    view6.layer.borderColor = qianhuicolor.CGColor;
    [MYmainScroll addSubview:view6];
       
    UILabel*beizhu=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth*70/750, 40)];
    beizhu.text=@"说明";
    beizhu.font= [UIFont systemFontOfSize:15];
    [beizhu setTextColor:qianheicolor];
    [view6 addSubview:beizhu];
        
            
            
    NSString *s1 = [[severDataDict.dataDict objectForKey:@"shelf"]objectForKey:@"remark"];
    UIFont *font1 = [UIFont systemFontOfSize:contenfot];
    CGSize size1 = CGSizeMake(ScreenWidth-60, 2000);
    CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
            
    UILabel*beizhu1=[[UILabel alloc]initWithFrame:CGRectMake(15, beizhu.bottom, ScreenWidth-40, labelsize1.height+10)];
    beizhu1.text=s1;
    beizhu1.numberOfLines=0;
    beizhu1.font= [UIFont systemFontOfSize:contenfot];
    [beizhu1 setTextColor:shenhuicolor];
    [view6 addSubview:beizhu1];
        
    view6.frame=CGRectMake(0, shangpingView.bottom+10, ScreenWidth, labelsize1.height+80);
    MYmainScroll.contentSize = CGSizeMake(ScreenWidth, view6.bottom+100);
        
        
        
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];

                
                
                
                
    
    
}
//盘点
-(void)shouying:(UIButton *)sender {
    
    
    
    
    if ([commdity.content length] < 1) {
        [self showAlertMessage:@"请选择类别！"];
    } else{
        
        
        
        NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
        NSString* Token = [user objectForKey:@"tokenId"];
        if (Token ==nil) {
            Token=@"dd";
        }
        
        NSMutableDictionary *params = [NSMutableDictionary new];
        [params setValue:Token forKey:@"tokenId"];
        [params setValue:self.whsId forKey:@"whsId"];
        [params setValue:leixingBtn1.titleLabel.text forKey:@"whsName"];
        [params setValue:commdity.code forKey:@"itemTypeCode"];
        [params setValue:commdity.content forKey:@"itemTypeName"];
        
        
        NSMutableArray *mDocumentLine=[NSMutableArray array];
        
        
        for (int i=0; i<commdity.ItemCode44.count; i++) {
            
            NSMutableDictionary *dic = [NSMutableDictionary dictionary];
            NSString *itemId = [commdity.ItemCode44 objectAtIndex:i];
            NSString *quantity =[commdity.how44 objectAtIndex:i];
            NSString *specId = [commdity.currentSpecId44 objectAtIndex:i];
            
            
            [dic setValue:quantity forKey:@"quantity"];
            [dic setValue:itemId forKey:@"itemId"];
            if ([specId isEqualToString:@""]) {
                
            }else{
                [dic setValue:specId forKey:@"specId"];
                
                
            }
            
            [mDocumentLine addObject:dic];
            
            
        }
        [params setValue:mDocumentLine  forKey:@"items"];
        [params setValue:tv.text  forKey:@"remark"];
        
        NSLog(@"33333333====%@",params);
        
        
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        
        
        [HttpRequest requestData:[NSString stringWithFormat:@"Business/%@/Add",@"CheckVouch"] params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                NSLog(@"33333333====%@",severDataDict.dataDict);
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
                    
                }else{
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    [Global showTextHudSub:requestResultStr view:self.view];
                }
                
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
            
        }];
        
    }
}

-(void)xuanzhidaogou1:(UIButton*)sender{
    
    [mainScroll removeFromSuperview];
    
    
    mainScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64+50+175/2, ScreenWidth, ScreenHeight)];
    mainScroll.delegate = self;
    mainScroll.userInteractionEnabled = YES;
    mainScroll.scrollEnabled = YES;
    mainScroll.backgroundColor=[UIColor whiteColor];
    mainScroll.alpha=0.89;
    [self.view addSubview:mainScroll];
    UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
    singleFingerOne.numberOfTouchesRequired = 1; //手指数
    singleFingerOne.numberOfTapsRequired = 1; //tap次数
    singleFingerOne.delegate = self;
    [mainScroll addGestureRecognizer:singleFingerOne];
    NSLog(@"%@",arrrss1);
    if (arrrss1.count>0) {
        
        for (int i = 0; i<arrrss1.count; i++) {
            
            daogouView = [[daogouview alloc]initWithFrame:CGRectMake(0, 0+(50*i), ScreenWidth, 50)];
            
            daogouView.buttonView.titleLabel.textAlignment=NSTextAlignmentCenter;
            daogouView.buttonView.titleLabel.font=[UIFont systemFontOfSize:contenfot];
            
            [daogouView.buttonView setTitle: [[arrrss1 objectAtIndex:i] objectForKey:@"whsName"] forState:UIControlStateNormal];
            daogouView.buttonView.backgroundColor=[UIColor whiteColor];
            daogouView.buttonView.tag=i;
            [daogouView.buttonView setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
            [daogouView.buttonView setTitleColor:shenhuicolor forState:0];
            [daogouView.buttonView addTarget:self action:@selector(daogouView1:) forControlEvents:UIControlEventTouchUpInside];
            
            [mainScroll addSubview:daogouView];
        }
        
        
        [mainScroll setContentSize:CGSizeMake(ScreenWidth, daogouView.bottom)];
    }
    
    
    
}



-(void)xuanzhidaogou:(UIButton*)sender{
    
    
    PlatformProductTypeListViewController *detailViewController = [[PlatformProductTypeListViewController alloc] init];
    [self.navigationController pushViewController:detailViewController animated:YES];
    
}
-(void)closeKeyBoad
{
    [mainScroll removeFromSuperview];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    MYmainScroll .frame =CGRectMake(0,view.bottom, ScreenWidth, ScreenHeight-300/2);
    [UIView commitAnimations];
    
    [tv resignFirstResponder];
}
-(void)daogouView1:(UIButton *)sender{
    
    
    self.whsId=[[arrrss1 objectAtIndex:sender.tag]objectForKey:@"id"];
    //    NSLog(@"%@",self.DocType);
    
    leixingBtn1.titleLabel.text=sender.titleLabel.text;
    [mainScroll removeFromSuperview];
}

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    MYmainScroll .frame =CGRectMake(0, -100, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];
    
    return self;
}

-(void)textViewDidChange:(UITextView *)textView
{
    //self.examineText =  textView.text;
    
    
    if (textView.text.length == 0) {
        [imagess removeFromSuperview];
        
        imagess=[[UIImageView alloc]initWithFrame:CGRectMake(0, 5, 51/3, 51/3)];
        imagess.image=[UIImage imageNamed:@"_0000_xingxifankui.png"];
        [tv addSubview:imagess];
        label.text = @"备注";
        
    }else{
        [imagess removeFromSuperview];
        label.text = @"";
    }
}


//回收键盘
-(void)OnTapDone{
    [tv resignFirstResponder];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    MYmainScroll .frame =CGRectMake(0,view.bottom, ScreenWidth, ScreenHeight-300/2);
    [UIView commitAnimations];
    
}

- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}


@end
